﻿<!DOCTYPE html>
<!-- saved from url=(0047)http://kindeditor.net/ke4/examples/default.html -->
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta charset="utf-8">
    <title>Default Examples</title>
    <style>
        form {
            margin: 0;
        }

        textarea {
            display: block;
        }
    </style>
    <link rel="stylesheet" href="themes/default/default.css" />
    <link rel="stylesheet" href="plugins/code/prettify.css" />
    <script src="../_Scripts/jquery/jquery.js?v=1.12.4" type="text/javascript"></script>
    <script charset="utf-8" src="kindeditor-min.js"></script>
    <script charset="utf-8" src="lang/zh_CN.js"></script>
    <script>
        var editor;
        //KindEditor.ready(function(K) {
        //    editor = K.create('textarea[name="content"]', {
        //        allowFileManager : true
        //    });
        //    K('input[name=getHtml]').click(function(e) {
        //        alert(editor.html());
        //    });
        //    K('input[name=isEmpty]').click(function(e) {
        //        alert(editor.isEmpty());
        //    });
        //    K('input[name=getText]').click(function(e) {
        //        alert(editor.text());
        //    });
        //    K('input[name=selectedHtml]').click(function(e) {
        //        alert(editor.selectedHtml());
        //    });
        //    K('input[name=setHtml]').click(function(e) {
        //        editor.html('<h3>Hello KindEditor</h3>');
        //    });
        //    K('input[name=setText]').click(function(e) {
        //        editor.text('<h3>Hello KindEditor</h3>');
        //    });
        //    K('input[name=insertHtml]').click(function(e) {
        //        editor.insertHtml('<strong>插入HTML</strong>');
        //    });
        //    K('input[name=appendHtml]').click(function(e) {
        //        editor.appendHtml('<strong>添加HTML</strong>');
        //    });
        //    K('input[name=clear]').click(function(e) {
        //        editor.html('');
        //    });
        //});

        KindEditor.ready(function (K) {
            editor = K.create('textarea[name="content"]', {
                cssPath: 'plugins/code/prettify.css',
                uploadJson: 'asp.net/upload_json.ashx',
                fileManagerJson: 'asp.net/file_manager_json.ashx',
                allowFileManager: true,
                //items: [
                //    'source', '|', 'undo', 'redo', '|', 'code', 'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter',
                //    'justifyright', 'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
                //    'superscript', 'clearhtml', 'selectall', '|', 'fullscreen', '/',
                //    'formatblock', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline', 'strikethrough',
                //    'lineheight', 'removeformat', '|', 'image', 'table', 'hr', 'emoticons', 'anchor', 'link', 'unlink', '|', 'about'
                //],
                afterCreate: function () {
                    var self = this;

                    // 给KindEditor绑定paste事件，用于粘贴截图
                    $(self.edit.doc).on("paste", function (e) {
                        // 需支持HTML5
                        if (!(!!window.ActiveXObject || "ActiveXObject" in window) && typeof(Worker) === "undefined") {
                            return;
                        }

                        var itmes = (e.clipboardData || e.originalEvent.clipboardData).items,
                            blob = null,
                            i,
                            length;

                        for (i = 0, length = itmes.length; i < length; i++) {
                            if (itmes[i].type.indexOf("image") === 0) {
                                blob = itmes[i].getAsFile();
                                break;
                            }
                        }

                        if (blob) {
                            var data = new FormData();
                            data.append("imgFile", blob, "screenshot.png");
                            data.append("BizObjectID", "xxx");
                            data.append("UserID", "yyy");
                            data.append("SchemaCode", "zzz");

                            $.ajax({
                                url: editor.uploadJson,
                                type: "POST",
                                data: data,
                                cache: false,
                                processData: false, // 告诉jQuery不要去处理发送的数据
                                contentType: false, // 告诉jQuery不要去设置Content-Type请求头
                                dataType: "json",
                                success: function (data) {
                                    if (data.error === 0) {
                                        editor.insertHtml("<img src=\"" + data.url + "\" alt=\"\" /> ");
                                    }
                                }
                            });
                        }
                    });
                }
            });
        });
    </script>
</head>
<body>
    <script type="text/javascript">
<!--
		google_ad_client = "ca-pub-7116729301372758";
		/* 更多演示（728x90） */
		google_ad_slot = "5052271949";
		google_ad_width = 728;
		google_ad_height = 90;
		//-->
    </script>
    <h3>默认模式</h3>
    <form>
        <textarea name="content" style="width: 800px; height: 400px;">KindEditor</textarea>
        <p>
            <input type="button" name="getHtml" value="取得HTML">
            <input type="button" name="isEmpty" value="判断是否为空">
            <input type="button" name="getText" value="取得文本(包含img,embed)">
            <input type="button" name="selectedHtml" value="取得选中HTML">
            <br>
            <br>
            <input type="button" name="setHtml" value="设置HTML">
            <input type="button" name="setText" value="设置文本">
            <input type="button" name="insertHtml" value="插入HTML">
            <input type="button" name="appendHtml" value="添加HTML">
            <input type="button" name="clear" value="清空内容">
            <input type="reset" name="reset" value="Reset">
        </p>
    </form>

</body>
</html>